package model
{
	import core.Control;
	
	import utils.ai.CheckPlayCard;
	import utils.ai.ReplyPlayCard;
	import utils.ai.AutoHintPlayCard;
	import utils.rule.IRuleResult;

	public class PlayCardModel
	{
		private var _control:Control = Control.getInstance();
		
		public function PlayCardModel()
		{
		}
		
		public function checkPlayCardDatas(currentPlayCardDatas:Array):IRuleResult
		{
			var ruleResult:IRuleResult;
			switch(currentPlayCardDatas.length)
			{
				case 1:
					ruleResult = CheckPlayCard.play1Card(currentPlayCardDatas);
					break;
				case 2:
					ruleResult = CheckPlayCard.play2Card(currentPlayCardDatas);
					break;
				case 3:
				case 4:
				case 5:
				case 6:
					ruleResult = CheckPlayCard.playMoreThan3Card(currentPlayCardDatas);
					break;
			}
			return ruleResult;
		}
		
		public function playLastCardDatas(lastPlayCardDatas:Array,currentPlayCardDatas:Array):IRuleResult
		{
			var ruleResult:IRuleResult;
			switch (lastPlayCardDatas.length)
			{
				case 0:
					ruleResult = checkPlayCardDatas(currentPlayCardDatas);
					break;
				case 1:
					ruleResult = ReplyPlayCard.replay1PlayCard(lastPlayCardDatas,currentPlayCardDatas);
					break;
				case 2:
					ruleResult = ReplyPlayCard.replay2PlayCard(lastPlayCardDatas,currentPlayCardDatas);
					break;
				case 3:
				case 4:
				case 5:
				case 6:
					ruleResult = ReplyPlayCard.replay3PlayCard(lastPlayCardDatas,currentPlayCardDatas);
					break;
				
			}
			return ruleResult;
		}
		
		public function autoPlayCardDatas(lastPlayCardDatas:Array,holdPlayCardDatas:Array):IRuleResult
		{
			var ruleResult:IRuleResult;
			
			if (lastPlayCardDatas == null)
			{
				return ruleResult;
			}
			
			switch (lastPlayCardDatas.length)
			{
				case 1:
					ruleResult = AutoHintPlayCard.autoHint1PlayCard(lastPlayCardDatas,holdPlayCardDatas);
					break;
				case 2:
					ruleResult = AutoHintPlayCard.autoHint2PlayCard(lastPlayCardDatas,holdPlayCardDatas);
					break;
				case 3:
				case 4:
				case 5:
				case 6:
					ruleResult = AutoHintPlayCard.autoHint3PlayCard(lastPlayCardDatas,holdPlayCardDatas);
					break;
			}
			return ruleResult;
		}
	}
}